import HTTP_CODE from '../constant/http-code'
import * as request from '../constant/fetch-request'

export const refreshStudentSections = assignmentInfo => {
  return {
    type: 'STUDENT_ASSIGNMENTS',
    assignmentInfo
  }
}


export const getStudentTasksSection = (programId, studentsId) => {
  return dispatch => {
    (async () => {
      const res = await request.get(`../api/v2/programs/${programId}/students/${studentsId}/assignments`)
      if (res.status === HTTP_CODE.OK) {
        dispatch(refreshStudentSections(res.body))
      }
    })()
  }
}
